Method: Rugged::Config#[]=

Defined in:
ext/rugged/rugged_config.c

#store(key, value) ⇒ Object #[]=(key) ⇒ Object

Store the given value in the Config file, under the section and name specified by key. Value can be any of the following Ruby types: String, true, false and Fixnum.

The config file will be automatically stored to disk.

cfg['apply.whitespace'] = 'fix'
cfg['diff.renames'] = true
cfg['gc.reflogexpre'] = 90
[View source]

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'ext/rugged/rugged_config.c', line 112

static VALUE rb_git_config_store(VALUE self, VALUE rb_key, VALUE rb_val)
{
	git_config *config;
	const char *key;
	int error;

	Data_Get_Struct(self, git_config, config);
	Check_Type(rb_key, T_STRING);

	key = StringValueCStr(rb_key);

	switch (TYPE(rb_val)) {
	case T_STRING:
		error = git_config_set_string(config, key, StringValueCStr(rb_val));
		break;

	case T_TRUE:
	case T_FALSE:
		error = git_config_set_bool(config, key, (rb_val == Qtrue));
		break;

	case T_FIXNUM:
		error = git_config_set_int32(config, key, FIX2INT(rb_val));
		break;

	default:
		rb_raise(rb_eTypeError,
			"Invalid value; config files can only store string, bool or int keys");
	}

	rugged_exception_check(error);
	return Qnil;
}